import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class WindowFont extends JFrame implements ItemListener {
   JComboBox list; 
   JTextArea text;
   WindowFont() {
     init();
     setVisible(true); 
     setBounds(100,120,300,300);
     setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);   
   }
   void init() {
     list=new JComboBox(); 
     text=new JTextArea();
     text.setForeground(new Color(0,29,236));
     list.setForeground(Color.blue);
     list.setBackground(Color.cyan);
     GraphicsEnvironment ge=GraphicsEnvironment.getLocalGraphicsEnvironment();
     String [] fontName=ge.getAvailableFontFamilyNames();
     for(String str:fontName)
         list.addItem(str);
     add(list,BorderLayout.NORTH);
     add(new JScrollPane(text),BorderLayout.CENTER);
     list.addItemListener(this);
   }
   public void itemStateChanged(ItemEvent e) {
     String name=(String)list.getSelectedItem();
     Font f=new Font(name,Font.BOLD,32);
     text.setFont(f);
     text.setText("\n2008北京奥运");
   }
}
